package com.agile.leetcode.array.sum;

/**
 * @Author ChenZhangKun
 * @Date 2020/7/24 16:07
 */
public class SqartPractice {
    static int s;
    public static void main(String[] args) {
        double v = fun_(2);
        System.out.println(v);
    }
    public static double fun_(int x){
        s=x;
        if (s==0) return 0;
        return fun_1(x);
    }

    private static double fun_1(double x) {
        double res=(x+s/x)/2;
        if (res==x) {return x;}else {
            return fun_1(res);
        }
    }
}
